package com.example.demo.jvm.packfinally;

/**
 * @Description TODO
 * @Author BG490350
 * @Date 2023/7/6 10:15
 **/
public class Test02 {

    public static int foo() {
        int x = 0;
        try {
            return x;
        }finally {
            ++x;
        }
    }

    public static String foo2() {
        String s1 = "s1";
        String s2 = "s2";
        try {
            return s1;
        }finally {
            return s2;
        }
    }

    public static String foo3() {
        String x="t1";
        try {
            return x;
        }finally {
            x=x+"t2";
        }
    }

    public static void main(String[] args) {

        System.out.println(foo());
        System.out.println(foo2());
        System.out.println(foo3());
    }
}
